<#global staticPath = "${request.contextPath}">
<!DOCTYPE html>
<html lang="en">
	<head>
	    <meta charset="utf-8">
	    <title>管理页面</title>
	    <meta name="description" content="">
	    <meta name="author" content="banyechan">
		<meta name="viewport" content="width=device-width, initial-scale=0.5,minimum-scale=0.5, maximum-scale=2.0, user-scalable=no"/>
		
		<link href="${staticPath}/css/bootstrap/css/bootstrap.min.css" rel="stylesheet">
		<link href="${staticPath}/css/font-awesome.min.css" rel="stylesheet">
		<link href="${staticPath}/css/chosen/chosen.min.css" rel="stylesheet"/>
		<link href="${staticPath}/css/pace.css" rel="stylesheet">
		<link href="${staticPath}/css/colorbox/colorbox.css" rel="stylesheet">
		<link href="${staticPath}/css/morris.css" rel="stylesheet">
		<link href="${staticPath}/css/endless.min.css" rel="stylesheet">
		<link href="${staticPath}/css/endless-skin.css" rel="stylesheet">
		<link href="${staticPath}/css/alertify/alertify.core.css" rel="stylesheet">
		<link href="${staticPath}/css/alertify/alertify.bootstrap.css" rel="stylesheet">
		
		<link href="${staticPath}/ICalendar/css/lCalendar.css" rel="stylesheet" type="text/css"/>
		
		<style type="text/css">
			::-webkit-scrollbar{width:0px}
		</style>
		
	</head>
	<body class="overflow-hidden">
		<div id="wrapper" class="preload">
			<#-- 顶部条 -->
			<div id="top-nav" class="fixed skin-6">
				<a href="#" class="brand"> <span>天下归一</span> <span class="text-toggle">道法自然</span> </a>			
				<button type="button" class="navbar-toggle pull-left" id="sidebarToggle">
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<button type="button" class="navbar-toggle pull-left hide-menu" id="menuToggle">
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<ul class="nav-notification clearfix">
					<li class="dropdown">
						<a class="dropdown-toggle" data-toggle="dropdown" href="#"> <strong>${(user.userName)!}</strong> </a>
					</li>
					<li class="dropdown hidden-xs">
					</li>
					<li class="dropdown">
						<a class="dropdown-toggle logoutConfirm_open" href="#logoutConfirm">
							<strong>退出</strong>
							<span></span>
						</a>
					</li>
				</ul>
			</div>
			<#--中间部分 -->
			<div id="main-container">
				<div class="padding-md" >
					<#-- 中间搜索部分 -->
					<div class="row" >
						<div class="panel panel-default">
							<div class="panel-body">
								<h3 style="text-align:center;color:black; font-weight:bold;">日班计划工作台</h3>	
							</div>
						</div>
					</div>
					
					<div class="row">
						<div class="col-md-2">
							<div class="panel panel-default">
								<#-- 车次显示部分 -->
								<div class="panel-body " style=" height:900px;overflow: auto;">
									<ul style="padding-left:8px;">
										<#if trainList?? && trainList?size gt 0>
											<#list trainList as train>
												<#if (train.state)?? && train.state == 1> 
												<a class="btn btn-default" onclick="getTrainInfo('${(train.id)!}')" href="#" style="width: 126px;margin-top:5px;margin-bottom: 5px;" >
													<li style="list-style: none;">${(train.trainName)!}</li>
												</a>
												<#elseif (train.state)?? && train.state == 2>
												<a class="btn btn-success" onclick="getTrainInfo('${(train.id)!}')" href="#" style="width: 126px;margin-top:5px;margin-bottom: 5px;" >
													<li style="list-style: none;">${(train.trainName)!}</li>
												</a>
												<#elseif (train.state)?? && train.state == 3>
												<a class="btn btn-warning" onclick="getTrainInfo('${(train.id)!}')" href="#" style="width: 126px;margin-top:5px;margin-bottom: 5px;" >
													<li style="list-style: none;">${(train.trainName)!}</li>
												</a>
												</#if>
											</#list>
										</#if>
									</ul>
								</div>
							</div>
						</div>
						
						<div class="col-md-8">
							<div class="panel panel-default">
								<div class="panel-body" style="height:900px;">
									<form  id="trainInfoForm" class="form-horizontal form-border" method="post" action="">
										<input type="hidden" name="id" id="id" value="${(firstTrain.id)!}"/>
										<input type="hidden" name="state" id="state" value="${(firstTrain.state)!}"/>
										<div class="form-group">
											<label class="col-md-2 control-label text-right">车次名称</label>
											<div class="col-md-3 ">
												<input class="form-control input-sm" type="text" id= "trainName" name="trainName" 
												   value="${(firstTrain.trainName)!}" readonly />
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-2 control-label">始发站</label>
											<div class="col-md-3">
												<select name="startStationId" class="form-control chzn-select" disabled>
													<option id="startStationId">${(firstTrain.startStationName)!}</option>
												</select>
											</div>
											<label class="col-md-2 control-label">终点站</label>
											<div class="col-md-3">
												<select name="endStationId" class="form-control chzn-select" disabled>
													<option id="endStationId">${(firstTrain.endStationName)!}</option>
												</select>
											</div>
										</div>	
										<#-- 
										<div class="form-group">
											<label class="col-md-2 control-label">前方站</label>
											<div class="col-md-3">
												<select name="frontStationId" class="form-control chzn-select" disabled>
													<option id="frontStationId" >${(firstTrain.frontStationName)!}</option>
												</select>
											</div>
											<label class="col-md-2 control-label">后方站</label>
											<div class="col-md-3">
												<select name="afterStationId" class="form-control chzn-select" disabled>
													<option id="afterStationId" >${(firstTrain.afterStationName)!}</option>
												</select>
											</div>
										</div>
										
										<div class="form-group">
											<label class="col-md-2 control-label">始发时间</label>
											<div class="col-md-4">
												<div class="input-group">
													<input id="startTime" name="startTimeStr" class="form-control" readonly
														value="<#if (firstTrain.startTime)??>${firstTrain.startTime?string('HH:mm:ss')}</#if>"/>
													<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
												</div>
											</div>
											<label class="col-md-2 control-label">终点站时间</label>
											<div class="col-md-4">
												<div class="input-group">
													<input id="endTime" name="endTimeStr" class="form-control" readonly
														value="<#if (firstTrain.endTime)??>${firstTrain.endTime?string('HH:mm:ss')}</#if>"/>
													<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
												</div>
											</div>
										</div>
										 -->
										<div class="form-group">
											<label class="col-md-2 control-label"><span class="text-danger">*</span>到站时间</label>
											<div class="col-md-4">
												<div class="input-group">
													<input id="reachTime" name="reachTimeStr" class="form-control" type="text"
														value="<#if (firstTrain.reachTime)??>${firstTrain.reachTime?string('HH:mm:ss')}</#if>"/>
													<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
												</div>
											</div>
											<label class="col-md-2 control-label"><span class="text-danger">*</span>离站时间</label>
											<div class="col-md-4">
												<div class="input-group">
													<input id="leaveTime" name="leaveTimeStr" class="form-control" type="text"
														value="<#if (firstTrain.leaveTime)??>${firstTrain.leaveTime?string('HH:mm:ss')}</#if>"/>
													<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
												</div>
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-2 control-label"><span class="text-danger">*</span>是否上水</label>
											<div class="col-md-4">
												<label class="label-radio inline">
													<input type="radio" name="isAddWater" id="isAddWater1" value="1" required="required" <#if (firstTrain.isAddWater)?? && firstTrain.isAddWater == 1>checked</#if> >
													<span class="custom-radio" style="font-size:26px">是</span>
												</label>
												<label class="label-radio inline">
													<input type="radio" name="isAddWater" id="isAddWater0" value="0" required="required" <#if (firstTrain.isAddWater)?? && firstTrain.isAddWater == 0>checked</#if> >
													<span class="custom-radio" style="font-size:26px;margin-left:6px">否</span>
												</label>
											</div>
											<label class="col-md-2 control-label"><span class="text-danger">*</span>是否去污</label>
											<div class="col-md-4">
												<label class="label-radio inline">
													<input type="radio" name="isDealRubbish" id="isDealRubbish1" value="1" required="required" <#if (firstTrain.isDealRubbish)?? && firstTrain.isDealRubbish == 1>checked</#if> >
													<span class="custom-radio" style="font-size:26px">是</span>
												</label>
												<label class="label-radio inline">
													<input type="radio" name="isDealRubbish" id="isDealRubbish0" value="0" required="required" <#if (firstTrain.isDealRubbish)?? && firstTrain.isDealRubbish == 0>checked</#if> >
													<span class="custom-radio" style="font-size:26px;margin-left:6px">否</span>
												</label>
											</div>
											<span id="targetUserTypeError"></span>
										</div>
										<div class="form-group">
											<label class="col-md-4 control-label"><span style="color: red">*</span>接,发车股道</label>
											<div class="col-md-3">
												<select name="pickUpTrack" id="pickUpTrack" class="form-control chzn-select"  onchange="changePickUpTrack()">
													<option value="0" data-isAddWater="0" data-isDealRubbish="0" > === </option>
													<#if trackList?? && trackList?size gt 0>
														<#list trackList as track>
															<option value="${(track.trackId)!}" data-isAddWater="${(track.isAddWater)!}" data-isDealRubbish="${(track.isDealRubbish)!}"
																<#if (firstTrain.pickUpTrack)?? && firstTrain.pickUpTrack==track.trackId>selected</#if>>${(track.trackOrder)!}股</option>
														</#list>
													</#if>
												</select>
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-2 control-label">来车方向</label>
											<div class="col-md-4">
												<select name="comeDirectionId" id="comeDirectionId" class="form-control chzn-select" readonly>
													<option value="${(firstTrain.comeDirectionId)!}">${(firstTrain.comeDirectionName)!}</option>
												</select>
											</div>
											<label class="col-md-2 control-label">发车方向</label>
											<div class="col-md-4">
												<select name="goDirectionId" id="goDirectionId" class="form-control chzn-select"  readonly>
													<option value="${(firstTrain.goDirectionId)!}">${(firstTrain.goDirectionName)!}</option>
												</select>
											</div>
										</div>
										
										<div class="form-group">
											<label class="col-md-2 control-label">接车路径序列</label>
											<div class="col-md-3">
												<input class="form-control input-sm" type="text" readonly
													id="pickUpSequence" name="pickUpSequence" value="${(firstTrain.pickUpSequence)!}"/>
												<input type="hidden" id="comeDirecSerial" value="${(comeDirec.serialNumber)!}">
											</div>
											<label class="col-md-2 control-label">发车路径序列</label>
											<div class="col-md-3">
												<input class="form-control input-sm" type="text" readonly
													 id="departureSequence"  name="departureSequence" value="${(firstTrain.departureSequence)!}"/>
												<input type="hidden" id="goDirecSerial" value="${(goDirec.serialNumber)!}">
											</div>
										</div>
										
										<div class="form-group">
											<label class="col-md-2 control-label text-right">机车名称</label>
											<div class="col-md-3 ">
												<input class="form-control input-sm" type="text" id= "locoName" name="locoName" 
												   value="${(firstTrain.locoName)!}" readonly />
											</div>
											<label class="col-md-2 control-label">担当局</label>
											<div class="col-md-3">
												<input class="form-control input-sm" type="text" readonly
													 id="bearBureauName"  name="bearBureauName" value="${(firstTrain.bearBureau)!}"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-2 control-label text-right">编组数</label>
											<div class="col-md-3 ">
												<input class="form-control input-sm" type="text" id= "marshallingNumber" name="marshallingNumber" 
												   value="${(firstTrain.marshallingNumber)!}" readonly />
											</div>
											<label class="col-md-2 control-label">定编数</label>
											<div class="col-md-3">
												<input class="form-control input-sm" type="text"  id="setNum" readonly name="setNum" value="${(firstTrain.setNum)!}"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-2 control-label text-right">编组类型</label>
											<div class="col-md-3 ">
												<select name="marshallingType" id="marshallingType" class="form-control chzn-select" readonly>
													<#if (firstTrain.marshallingType)?? && firstTrain.marshallingType == 1>
														<option value="${(firstTrain.marshallingType)!}" selected >短编</option>
													<#elseif (firstTrain.marshallingType)?? && firstTrain.marshallingType == 2>
														<option value="${(firstTrain.marshallingType)!}" selected >长编</option>
													<#elseif (firstTrain.marshallingType)?? && firstTrain.marshallingType == 3>
														<option value="${(firstTrain.marshallingType)!}" selected >混合编</option>
													</#if>
												</select>
											</div>
										</div>
										
										<div class="panel-footer text-center">
											<#if (firstTrain.state)?? && firstTrain.state == 1>
												<button type="button" class="btn btn-success" id="submitButtonSave" >确定核对</button>
											<#elseif (firstTrain.state)?? && firstTrain.state == 2>
												<button type="button" class="btn btn-success" id="submitButtonSave" disabled >确定核对</button>
											</#if>
											<button type="button" class="btn btn-default" id="cancelButton" >取消核对</button>
										</div>
									</form>
								</div>
							</div>
						</div>
						<div class="col-md-2" >
							<div class="panel panel-default">
								<div class="panel-body" style=" height:900px;" >
									<div class="form-group">
										<a class="btn btn-danger btn-xs" onclick="deleteData()" style="margin-top:20px">
											<i class="fa fa-wrench fa-lg"></i> 删除旧数据
										</a>
										<a href="#addForm" class="btn btn-info btn-xs" data-toggle="modal" style="margin-top:20px">
											<i class="fa fa-plus fa-lg"></i> 生成新的日计划
										</a>
										<a href="#serchDiv" class="btn btn-warning btn-xs" data-toggle="modal" style="margin-top:20px;">
											<i class="fa fa-plus fa-lg"></i> 条件搜索 
										</a>
									</div>
									<div class="form-group" style="margin-top:300px">
										<label style="color:red">提示信息：</label>
										<div class="col-md-12">
											<textarea class="form-control" rows="8" id="tipMessage"></textarea>
										</div>
									</div>
								</div>
							</div>	
						</div>
						
					</div>	
				</div>
			</div>
		 </div>
		 
		<#-- 上传文件form -->
		<div class="modal fade" id="addForm">
			<div class="modal-dialog">
				<div class="modal-content">
	  				<div class="modal-header">
	    				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4>请选择您要上传的文件</h4>
	  				</div>
				    <div class="modal-body">
						<form id="fileUploadForm" class="form-horizontal form-border" method="post"  enctype="multipart/form-data">
							<div class="form-group">
								<label class="control-label col-md-2">文件：</label>
								<div class="col-md-8">
									<div class="upload-file">
										<input type="file" id="file" name="file" class="upload-demo">
										<label data-title="选择文件" for="file">
											<span data-title="未选择文件..."></span>
										</label>
									</div>
								</div>
							</div>
							<div class="form-group text-center">
								<button type="button" class="btn btn-success" onclick="uploadFile()"> 上传文件  </button>
								<button type="button" class="btn btn-default" data-dismiss="modal"> 取消  </button>
							</div>
						</form>
				    </div>
			  	</div>
			</div>
		</div>
		
		<#-- 条件搜索form -->
		<div class="modal fade" id="serchDiv">
			<div class="modal-dialog">
				<div class="modal-content">
	  				<div class="modal-header">
	    				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4>条件搜索</h4>
	  				</div>
					<div class="modal-body">
						<form class="form-horizontal form-border" id="serchForm" action="/dailyPlan/workList"  method="post">
							<div class="form-group">
								<label class="col-md-3 control-label text-right">车次名称</label>
								<div class="col-md-6 ">
									<input class="form-control input-sm" type="text" name="trainName" value="${(train.trainName)!}"  />
								</div>
							</div>
							<div class="form-group">
								<label class="col-md-2 control-label">始发站</label>
								<div class="col-md-4">
									<select name="startStationId" class="form-control chzn-select">
										<option value="">全部</option>
										<#if stationList?? && stationList?size gt 0>
											<#list stationList as station>
												<option value="${(station.stationId)!}"  <#if (train.startStationId)?? && train.startStationId == station.stationId>selected</#if> >${(station.stationName)!}</option>
											</#list>
										</#if>
									</select>
								</div>
								<label class="col-md-2 control-label">终点站</label>
								<div class="col-md-4">
									<select name="endStationId" class="form-control chzn-select">
										<option value="">全部</option>
										<#if stationList?? && stationList?size gt 0>
											<#list stationList as station>
												<option value="${(station.stationId)!}" <#if (train.endStationId)?? && train.endStationId == station.stationId>selected</#if>>${(station.stationName)!}</option>
											</#list>
										</#if>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-md-2 control-label">上水</label>
								<div class="col-md-4">
									<select name="isAddWater" class="form-control chzn-select">
										<option value="">全部</option>
										<option value="0" <#if (train.isAddWater)?? && train.isAddWater == 0>selected</#if>>否</option>
										<option value="1" <#if (train.isAddWater)?? && train.isAddWater == 1>selected</#if>>是</option>
									</select>
								</div>
								<label class="col-md-2 control-label">去污</label>
								<div class="col-md-4">
									<select name="isDealRubbish" class="form-control chzn-select">
										<option value="">全部</option>
										<option value="0" <#if (train.isDealRubbish)?? && train.isDealRubbish == 0>selected</#if>>否</option>
										<option value="1" <#if (train.isDealRubbish)?? && train.isDealRubbish == 1>selected</#if>>是</option>
									</select>
								</div>
							</div>	
							<input type="hidden" name="workTrainId" id="workTrainId" value=""/>	
							<div class="form-group text-center">
								<button type="submit" class="btn btn-success"> 搜索  </button>
								<button type="button" class="btn btn-default" data-dismiss="modal"> 关闭  </button>
							</div>
						</form>	
					</div>
				</div>
			</div>
		</div>
		<#-- 退出登录  -->
		<div class="custom-popup width-100" id="logoutConfirm">
			<div class="padding-md">
				<h4 class="m-top-none">你确定要退出登录?</h4>
			</div>
			<div class="text-center">
				<a class="btn btn-success m-right-sm" href="/user/loginOut">退出</a>
				<a class="btn btn-danger logoutConfirm_close">取消</a>
			</div>
		</div>
		
		<script src="${staticPath}/js/jquery-1.10.2.min.js"></script>
		<script src="${staticPath}/js/bootstrap.min.js"></script>
		<script src='${staticPath}/js/chosen.jquery.min.js'></script>	
		<script src='${staticPath}/js/rapheal.min.js'></script>	
		<script src='${staticPath}/js/morris.min.js'></script>	
		<script src='${staticPath}/js/jquery.colorbox.min.js'></script>	
		<script src='${staticPath}/js/jquery.sparkline.min.js'></script>
		<script src='${staticPath}/js/pace.js'></script>
		<script src='${staticPath}/js/jquery.popupoverlay.min.js'></script>
		<script src='${staticPath}/js/jquery.slimscroll.min.js'></script>
		<script src='${staticPath}/js/modernizr.min.js'></script>
		<script src='${staticPath}/js/jquery.cookie.min.js'></script>
		<script src="${staticPath}/js/endless/endless.js"></script>
		<script src="${staticPath}/js/parsley.min.js"></script>
		<script src="${staticPath}/js/alertify/alertify.min.js"></script>
		
		<script src="${staticPath}/ICalendar/js/lCalendar.js"></script>
		
		<script>
			var calendartime = new lCalendar();
			calendartime.init({
				'trigger': '#reachTime',
				'type': 'time'
			});
			
			var calendartime = new lCalendar();
			calendartime.init({
				'trigger': '#leaveTime',
				'type': 'time'
			});
			
			$("#reachTime,#leaveTime").focus(function(){
        		document.activeElement.blur();
   			 });
			
		</script>
		<script>
			function getTrainInfo(trainId){
				if(trainId != ""){
					$("#workTrainId").val(trainId);
					$("#serchForm").submit();
				}
			}
			
			function deleteData (){
				alertify.confirm("确定删除吗？",function (e) {
					if(e){
						alertify.success("你点击了确定");
						$.ajax({
							cache: true,
							type: "POST",
							url:"/dailyPlan/deleteAll",
							async: false,
							error: function(request) {
								alertify.alert("错误：服务器异常！");
							},
							success: function(data) {
								if(data.success){
									alertify.alert("删除成功！",function(){
										window.location.reload();
									});
								}else{
									alertify.alert("错误:" + data.message);
								}
							}
						});
				    }else{
						alertify.error("你点击了取消");
				    }
				});
			}
			
			
			function uploadFile(){
				var fileName = $('#file').val();
				if($.trim(fileName) != ""){
					var i = fileName.indexOf(".xls");
					if(i != -1){
						var formData = new FormData(document.getElementById("fileUploadForm"));  
						$.ajax({
							cache: true,
							type: "POST",
							url:"/dailyPlan/fileUpload",
							data:formData,
							async: false,
							contentType: false,
							processData: false,
							error: function(request) {
								alertify.alert("错误：服务器异常！");
							},
							success: function(data) {
								if(data.success){
									alertify.alert("文件上传成功！",function(){
										window.location.reload();
									});
								}else{
									alertify.alert("错误:" + data.message);
								}
							}
						});
					}else{
						alertify.alert("请上传EXCLE文件");
						return;
					}
				}else{
					alertify.alert("请选择要上传的文件");
					return;
				}
			}
			
		//修改接发车股道
		function changePickUpTrack(){
			var trackId = $('#pickUpTrack option:selected') .val();
			var track_isAddWater = $('#pickUpTrack option:selected') .attr('data-isAddWater');
			var track_isDealRubbish = $('#pickUpTrack option:selected') .attr('data-isDealRubbish');
			
			var isAddWater = $('input[name="isAddWater"]:checked').val();
			var isDealRubbish = $('input[name="isDealRubbish"]:checked').val();
			
			var comeDirecSerial = $("#comeDirecSerial").val(); 
			var newSerial = comeDirecSerial.replace('?',trackId);
			$("#pickUpSequence").val(newSerial);
			
			var goDireSerial = $('#goDirecSerial').val();
			var gonewSerial = goDireSerial.replace('?',trackId);
			$("#departureSequence").val(gonewSerial);
			
			var tip = "";
			if(track_isAddWater != "" && isAddWater == "1" && track_isAddWater != isAddWater){
				tip += "所选股道不支持上水！！！ \n ";
			}
			if(track_isDealRubbish != "" && isDealRubbish == "1" && track_isDealRubbish != isDealRubbish){
				tip += "所选股道不支持去污！！！";
			}
			if(tip != ""){
				alertify.alert("提示：" + tip);
			}
			$("#tipMessage").text(tip);
		}
			
		//确定核对
		$("#submitButtonSave").click(function(){
			var reachTime = $("#reachTime").val();
			if($.trim(reachTime) == "" ){
				alertify.alert("请输入到站时间。");
				return false;
			}
			var leaveTime = $("#leaveTime").val();
			if($.trim(leaveTime) == "" ){
				alertify.alert("请输入离站时间。");
				return false;
			}	
			var isAddWater = $('input[name="isAddWater"]:checked').val();
			if($.trim(isAddWater) == "" ){
				alertify.alert("请选择是否上水。");
				return false;
			}
			var isDealRubbish = $('input[name="isDealRubbish"]:checked').val();							
			if($.trim(isDealRubbish) == "" ){
				alertify.alert("请选择是否去污。");
				return false;
			}
			var pickUpTrack = $('#pickUpTrack option:selected') .val();											
			if($.trim(pickUpTrack) == "" || pickUpTrack == "0" ){
				alertify.alert("请选择有效的股道。");
				return false;
			}
		
			$("#state").val(2);
			$.ajax({
				cache: true,
				type: "POST",
				url:"/dailyPlan/workSave",
				data:$('#trainInfoForm').serialize(),
				async: false,
				error: function(request) {
					alertify.alert("错误：服务器异常！");
				},
				success: function(data) {
					if(data.success){
						alertify.alert("保存成功！",function(){
							window.location.reload();
						});
					}else{
						alertify.alert("错误:" + data.message);
					}
				}
			});
		});
			
		//取消核对
		$("#cancelButton").click(function(){
			$("#state").val(1);
			$.ajax({
				cache: true,
				type: "POST",
				url:"/dailyPlan/workSave",
				data:$('#trainInfoForm').serialize(),
				async: false,
				error: function(request) {
					alertify.alert("错误：服务器异常！");
				},
				success: function(data) {
					if(data.success){
						alertify.alert("保存成功！",function(){
							window.location.reload();
						});
					}else{
						alertify.alert("错误:" + data.message);
					}
				}
			});
		});
			
	</script>
	</body>
</html>